﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Configuration;

namespace TZS.Codigo
{
    public class FicheroDNI
    {
        public string Nombre { get; set; }
        public string URL { get; set; }

        public List<FicheroDNI> TraerDNI()
        {
            string carpeta = HttpContext.Current.Server.MapPath(string.Format(ConfigurationManager.AppSettings["URLParaDNI"], ""));
            List<FicheroDNI> lista = new List<FicheroDNI>();

            foreach (string item in Directory.GetFiles(carpeta))
            {
                string[] array = item.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                string nombre = array[array.Length - 1];
                lista.Add(new FicheroDNI() { Nombre = nombre, URL = string.Format(ConfigurationManager.AppSettings["URLParaDNI"], nombre) });
            }

            return lista;
        }
    }
}